<!--
 * @Description: 泵送作业结算
 * @Author: wangwangwang
 * @Date: 2020-09-21 14:09:06
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-12-29 15:09:37
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>

      <el-main>
        <!-- 导航 -->
        <div class="tabtop">
          <div v-for="(item, index) in navlist" :key="index" @click="choose(item.id)">
            <div :class="currenindex == index + 1 ? 'active' : 'text'">{{ item.value }}</div>
            <div v-if="currenindex !== index + 1 && currenindex !== index + 2 && index !== 2" class="hr"></div>
          </div>
        </div>
        <!-- 搜索条件 -->
        <div v-loading="pagesLoading">
          <!-- 折叠 -->
          <div class="header_right" @click="showCardNav = !showCardNav">
            <div class="title">搜索</div>
            <div>
              <transition name="from"></transition>
              <span v-show="!showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
              </span>
              <transition name="to"></transition>
              <span v-show="showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-up"></i>
              </span>
            </div>
          </div>
          <div v-show="showCardNav" class="hr"></div>
          <!-- 搜索内容 -->
          <el-collapse-transition>
            <div v-show="showCardNav" style="padding-top:18px">
              <el-form :inline="true" label-width="110px">
                <!-- 搜索条件1 -->
                <el-form-item v-if="currenindex==1" label-width="160px">
                  <span slot="label">泵送单位</span>
                  <div style="width:240px;height:36px;display:flex;">
                    <div :title="searchText" style="width:180px;padding:0 10px;border-bottom: 1px solid #bbb;margin-right:5px;" class="ellipsis">{{searchText}}</div>
                    <el-button class="bottom_all_two" @click="getsearchData(),search=true">选择</el-button>
                  </div>
                </el-form-item>
                <el-form-item v-if="currenindex==1">
                  <span slot="label">结算时间段</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始时间" end-placeholder="结束时间" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <!-- 搜索条件2 -->
                <el-form-item v-if="currenindex==2">
                  <span slot="label">泵送单位</span>
                  <el-select v-model="tableParam.pumpingTeamId" placeholder="请选择">
                    <el-option v-for="(item,index) in searchData" :key="index" :label="item.supplierName" :value="item.supplierId"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==2">
                  <span slot="label">结算单号</span>
                  <el-input v-model="tableParam.finalStatementNum" placeholder="请输入" clearable></el-input>
                </el-form-item>
                <el-form-item v-if="currenindex==2">
                  <span slot="label">泵送时间</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始时间" end-placeholder="结束时间" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <!-- 搜索条件3 -->
                <el-form-item v-if="currenindex==3">
                  <span slot="label">结算单号</span>
                  <el-input v-model="tableParam.statementNo" placeholder="请输入" clearable></el-input>
                </el-form-item>
                <el-form-item v-if="currenindex==3">
                  <span slot="label">泵送单位</span>
                  <el-select v-model="tableParam.unitId" placeholder="请选择">
                    <el-option v-for="(item,index) in searchData" :key="index" :label="item.supplierName" :value="item.supplierId"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item v-if="currenindex==3">
                  <span slot="label">提交时间</span>
                  <el-date-picker v-model="datePicker" style="height:36px" type="datetimerange" unlink-panels align="right" start-placeholder="开始时间" end-placeholder="结束时间" :default-time="['12:00:00', '08:00:00']" value-format="yyyy-MM-dd HH:mm:ss">
                  </el-date-picker>
                </el-form-item>
                <el-form-item>
                  <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam.page = 1), pagesgettableData()">查 询</el-button>
                  <el-button v-if="currenindex!=1" size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
                </el-form-item>
              </el-form>
            </div>
          </el-collapse-transition>
          <div class="hr"></div>
          <!-- 页面内容区 -->
          <div class="card" :style="currenindex!==1?'padding-top:10px':''">
            <!-- 页面功能按钮区 -->
            <div v-show="currenindex==1" class=" card_nav">
              <div>
                <el-button v-if="ButtonList.findIndex(res=>(res.buttonValue=='SHENGCJSD'))!==-1" size="small" class="bottom_three" :disabled="generate.punList.length==0" @click="statements()">
                  生成结算单
                </el-button>
              </div>
              <div>
              </div>
            </div>
            <!-- 表格数据 -->
            <div v-loading="tableLoading" class="card_info" :style="style">
              <el-table ref="table" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark" @selection-change="tableChange">
                <el-table-column v-if="currenindex==1" align="center" type="selection"></el-table-column>
                <template v-for="(item, index2) in table">
                  <el-table-column v-if="item.status" :key="index2" :label="item.label" align="center" :min-width="item.width" :fixed="item.label =='操作'?'right':false">
                    <template slot-scope="scope">
                      <div v-if="item.label == '浇筑方式'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '结算单号'" class="table_link" @click="show(scope.row)">
                        {{ scope.row[item.prop] }}
                      </div>
                      <div v-else-if="item.label == '高度/臂长(米)'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '浇筑量（方）'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '单价(元/方)'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '泵送时间'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '泵管使用'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '结算费用（元）'&&currenindex==1">
                        <div v-for="(item1,index1) in scope.row.list" :key="index1">
                          {{item1[item.prop]}}
                        </div>
                      </div>
                      <div v-else-if="item.label == '序号'">
                        {{scope.$index+1}}
                      </div>
                      <div v-else-if="item.label == '结算时间段'">
                        {{scope.row.startTime+'-'+scope.row.endTime}}
                      </div>
                      <span v-else-if="item.label == '内部审核状态'">
                        {{scope.row.auditStatus==1?'待提交':scope.row.auditStatus==2?'审核中':scope.row.auditStatus==3?'通过':'未通过'}}
                      </span>
                      <span v-else-if="item.label == '操作'">
                        <!-- <span v-if="scope.row.auditStatus==3" class="table_link" @click="send(scope.row)">
                          发送
                        </span> -->
                        <el-button v-if="scope.row.auditStatus==3" size="mini" class="bottom_all_two" @click="userSubmit(scope.row)">
                          发送
                        </el-button>
                        <el-button v-if="billDetails1.auditStatus==1" size="mini" class="bottom_all_two" @click="$router.push({ name: 'sign_Wise_rentunit3', query: { id: scope.row.statementNo, type: 1 } })">提交审核</el-button>
                      </span>
                      <span v-else-if="item.label == '供应商确认'">
                        {{scope.row.supplierConfirm==1?'待查看':scope.row.supplierConfirm==2?'通过':'未发送'}}
                      </span>
                      <span v-else>{{ scope.row[item.prop] }}</span>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div>
          </div>
        </div>
      </el-main>
      <div v-if="currenindex!==1" class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" :page-sizes="[10, 20, 30, 40,50,100,200,500,1000]" layout="prev,pager,sizes,next,jumper" :total="total" @size-change="sizeChange" @current-change="pagesgettableData()"></el-pagination>
        </div>
        <div>
          <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="pagesgettableData()">刷新</el-button>
        </div>
      </div>
    </el-container>
    <!-- 选择供应商合同 -->
    <el-dialog v-dialogDrag :visible.sync="search" width="680px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">选择泵送队</span>
      <div class="dialoginfo">
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="searchData" tooltip-effect="dark" @row-click='setradio'>
          <el-table-column align="center" label="选择">
            <template slot-scope="scope">
              <el-radio :value="searchradio" :label="JSON.stringify(scope.row)">{{''}}</el-radio>
            </template>
          </el-table-column>
          <el-table-column align="center" label="合同编号" prop="contractNumber"></el-table-column>
          <el-table-column align="center" label="合同单位" prop="supplierName"></el-table-column>
          <el-table-column align="center" label="合作等级" prop="cooperationClass"></el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="search=false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="submitsearch">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 泵送结算单 -->
    <el-dialog v-dialogDrag :visible.sync="billDeta" width="1180px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">泵送结算单</span>
      <div ref="html" style="padding:10px 20px">
        <div class="bill_top">
          <span><span class="text">泵送单位：</span>{{billDetails.pumpingTeam}}</span>
          <span><span class="text">结算时间段：</span>{{billDetails.startTime}}至{{billDetails.endTime}}</span>
          <span><span class="text">结算单编号：</span>{{billDetails.finalStatementNum}}</span>
        </div>
        <div class="bill_title1">泵送费用</div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billList" tooltip-effect="dark">
          <el-table-column label="站点" align="center" prop="pointName"></el-table-column>
          <el-table-column label="泵类别" align="center" prop="pumpType"></el-table-column>
          <el-table-column label="臂长&高度（米）" align="center" prop="heighScope"></el-table-column>
          <el-table-column label="泵送数量（方）" align="center" prop="num"></el-table-column>
          <el-table-column label="基本单价(元/方)" align="center" prop="basicUnitPrice"></el-table-column>
          <el-table-column label="结算单价(元)" align="center" prop="">
            <template slot-scope="scope">
              <el-input v-model="scope.row.closeUnitPrice" type="Number" style="width:100%" placeholder="请输入" clearable></el-input>
            </template>
          </el-table-column>
          <el-table-column label="结算金额（元）" align="center">
            <template slot-scope="scope">
              {{scope.row.closeSumMoney=Number(scope.row.closeUnitPrice)*Number(scope.row.num)}}
            </template>
          </el-table-column>
        </el-table>
        <div class="combined">小计：泵送数量【{{combined(billList)}}】，结算金额【{{combined1(billList)}}】</div>
      </div>
      <span slot="footer" class="dialog-footer" style="display:flex;justify-content: space-between;">
        <div>
          <!-- <el-button class="bottom_all_two" @click="downloadLink">打印结算单</el-button> -->
          <el-button class="bottom_all_two" @click="combinedSubmit(2)">提交审核</el-button>
        </div>
        <div>
          <el-button class="bottom_all_two" @click="billDeta=false">取 消</el-button>
          <el-button class="bottom_all" style="margin-left: 24px" @click="combinedSubmit(1)">保 存</el-button>
        </div>
      </span>
    </el-dialog>
    <!-- 泵送结算单 -->
    <el-dialog v-dialogDrag :visible.sync="billDeta1" width="1180px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">泵送结算单</span>
      <div ref="html" style="padding:10px 20px">
        <div class="bill_top">
          <span><span class="text">泵送单位：</span>{{billDetails1.pumpingTeam}}</span>
          <span><span class="text">结算时间段：</span>{{billDetails1.startTime}}至{{billDetails1.endTime}}</span>
          <span><span class="text">结算单编号：</span>{{billDetails1.finalStatementNum}}</span>
        </div>
        <div class="bill_title1">泵送费用</div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="billDetails1.list" tooltip-effect="dark">
          <el-table-column label="站点" align="center" prop="pointName"></el-table-column>
          <el-table-column label="泵类别" align="center" prop="pumpType"></el-table-column>
          <el-table-column label="臂长&高度（米）" align="center" prop="heighScope"></el-table-column>
          <el-table-column label="泵送数量（方）" align="center" prop="num"></el-table-column>
          <el-table-column label="基本单价(元/方)" align="center" prop="basicUnitPrice"></el-table-column>
          <el-table-column label="结算单价(元)" align="center" prop="closeUnitPrice">
          </el-table-column>
          <el-table-column label="结算金额（元）" align="center" prop="closeSumMoney">
          </el-table-column>
        </el-table>
        <div class="combined">小计：泵送数量【{{combined(billDetails1.list)}}】，结算金额【{{combined1(billDetails1.list)}}】</div>
      </div>
      <span slot="footer" class="dialog-footer" style="display:flex;justify-content: space-between;">
        <div>
          <el-button class="bottom_all_two" @click="downloadLink">打印结算单</el-button>
          <el-button v-if="billDetails1.auditStatus==1" class="bottom_all_two" @click="combinedSubmit(3)">提交审核</el-button>
        </div>
        <div>
          <el-button class="bottom_all_two" @click="billDeta1=false">取 消</el-button>
        </div>
      </span>
    </el-dialog>
    <!--选择发送的人员-->
    <!-- <el-dialog v-dialogDrag :visible.sync="userDeta" width="620px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">请选择接收账号</span>
      <div style="padding:0 10px">
        <el-checkbox-group v-model="userarr">
          <template v-for="(item,index) in useroptons">
            <el-checkbox :key="index" style="line-height:26px" :label="item.id">{{item.name}}</el-checkbox>
          </template>
        </el-checkbox-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="userDeta=false">取 消</el-button>
        <el-button class="bottom_all" :disabled="userarr.length==0" style="margin-left: 24px" @click="userSubmit()">发 送</el-button>
      </span>
    </el-dialog> -->
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  queryPage1, getContractVoList, generateStatement, saveOrUpdate, queryPage3, queryPage2, queryMany, update_status, Download
} from "@/api/wise/Wise_rentunit/Wise_rentunit3.js";
import {
  // queryUserByID,
  informClient,
} from "@/api/wise/Wise_contactsbusiness/Wise_contactsbusiness.js";
import { uploadFile } from '@/api/common.js'
import html2canvas from 'html2canvas';
export default {
  mixins: [mixin],
  data() {
    return {
      pagesLoading: false,
      /*表格增删改查及下载接口*/
      queryPage: '',
      /*表格数据*/
      table: [],
      table1: [
        { label: "工程名称", width: "140", prop: "engineeringName", status: true },
        { label: "客户名称", width: "140", prop: "roadwork", status: true },
        { label: "订单号", width: "140", prop: "orderNo", status: true },
        { label: "运输号", width: "140", prop: "transportNum", status: true },
        { label: "车牌号", width: "140", prop: "carNo", status: true },
        { label: "产品名称", width: "140", prop: "productName", status: true },
        { label: "生产站点", width: "140", prop: "pointName", status: true },
        { label: "浇筑方式", width: "140", prop: "pouringMethod", status: true },
        { label: "高度/臂长(米)", width: "140", prop: "height", status: true },
        { label: "浇筑量（方）", width: "140", prop: "num", status: true },
        { label: "单价(元/方)", width: "140", prop: "unitPrice", status: true },
        { label: "泵送时间", width: "166", prop: "pumpTime", status: true },
        { label: "泵管使用", width: "140", prop: "pumpLineUse", status: true },
        { label: "结算费用（元）", width: "140", prop: "closingCost", status: true },
      ],
      table2: [
        { label: "工程名称", width: "140", prop: "engineeringName", status: true },
        { label: "客户名称", width: "140", prop: "roadwork", status: true },
        { label: "订单号", width: "220", prop: "orderNo", status: true },
        { label: "运输号", width: "320", prop: "transportNum", status: true },
        { label: "车牌号", width: "140", prop: "carNo", status: true },
        { label: "产品名称", width: "140", prop: "productName", status: true },
        { label: "生产站点", width: "140", prop: "pointName", status: true },
        { label: "浇筑方式", width: "140", prop: "pouringMethod", status: true },
        { label: "高度/臂长(米)", width: "140", prop: "height", status: true },
        { label: "浇筑量（方）", width: "140", prop: "num", status: true },
        { label: "单价(元/方)", width: "140", prop: "unitPrice", status: true },
        { label: "泵送时间", width: "166", prop: "pumpTime", status: true },
        { label: "泵管使用", width: "140", prop: "pumpLineUse", status: true },
        { label: "结算费用（元）", width: "140", prop: "closingCost", status: true },
        { label: "结算单号", width: "140", prop: "finalStatementNum", status: true },
      ],
      table3: [
        { label: "序号", width: "50", prop: "", status: true },
        { label: "结算单号", width: "310", prop: "statementNo", status: true },
        { label: "运输供应商", width: "160", prop: "unitName", status: true },
        { label: "结算时间段", width: "310", prop: "", status: true },
        { label: "结算总金额（元）", width: "150", prop: "statementAmount", status: true },
        { label: "提交时间", width: "160", prop: "submitTime", status: true },
        { label: "内部审核状态", width: "120", prop: "", status: true },
        { label: "操作", width: "130", prop: "", status: true },
        { label: "供应商确认", width: "120", prop: "", status: true },
      ],
      pagesType: 0,
      /**导航栏*/
      navlist: [
        {
          value: "待结算",
          id: 1,
        },
        {
          value: "已结算",
          id: 2,
        },
        {
          value: "结算单",
          id: 3,
        },
      ],
      currenindex: 1,
      /**时间*/
      datePicker: [],
      /**搜索条件1*/
      searchText: '',
      search: false,
      searchData: [],
      searchradio: '',
      /**生成结算的数据*/
      generate: {
        punList: [],
        pumpingTeamId: '',
        startTime: '',
        endTime: '',
        pumpingTeam: ''
      },
      /*结算单详情*/
      billDeta: false,
      billDetails: {},
      billList: [],
      totalList: [],
      billDeta1: false,
      billDetails1: {
        list: [],
      },
      low: '',
      userDeta: false,
      useroptons: [],
      userarr: [],
      download: Download,
    };
  },
  created() {
    /*存储拷贝的原初始化fromDate数据*/

  },
  watch: {
    /**导航切换*/
    currenindex: {
      handler() {
        this.tableData = []
        this.datePicker = []
        this.tableParam = this.$options.data().tableParam
        if (this.currenindex == 1) {
          this.table = this.table1;
          this.queryPage = queryPage1
          this.searchText = ''
          this.tableParam = {
            pumpingTeamId: '',
            pumpingTeam: '',
            startTime: '',
            endTime: ''
          }
        }
        if (this.currenindex == 2) {
          this.table = this.table2;
          this.queryPage = queryPage2
          this.gettableData()
        }
        if (this.currenindex == 3) {
          this.table = this.table3;
          this.tableParam.statementType = 2
          this.queryPage = queryPage3
          this.gettableData()
        }
        this.pagesLoading = false
        //此处为执行的函数或者方法
      },
      deep: false,
      immediate: true,
    },
    /**时间选择*/
    datePicker() {
      if (this.datePicker) {
        this.tableParam.startTime = this.datePicker[0]
        this.tableParam.endTime = this.datePicker[1]
      } else {
        this.tableParam.startTime = ''
        this.tableParam.endTime = ''
      }
    },
    /**table1默认全选*/
    tableData() {
      if (this.tableData.length !== 0 && this.currenindex == 1) {
        this.$refs.table.toggleAllSelection()
      }
    },
  },
  methods: {
    downloadLink() {
      this.$Download(this.download, { statementNo: this.low.statementNo })
    },
    /**结算单发给供应商*/
    // send(low) {
    //   this.low = low
    //   this.userarr = []
    //   this.useroptons = []
    //   queryUserByID({ id: low.contractId }).then(res => {
    //     console.log(this.low)
    //     this.useroptons = JSON.parse(res.data)
    //     this.userDeta = true
    //   })
    // },
    async userSubmit(low) {
      this.$confirm('确认发送?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
        type: 'warning'
      }).then(async () => {
        let json = {
          contractId: low.contractId,
          type: 4,
          settlementId: low.id,
          settlementNo: low.statementNo,
          times: low.startTime + '-' + low.endTime,
          money: low.statementAmount,
          applyForTime: low.createTime,
          imgUrl: low.picture,
        }
        // let arr = this.userarr.map(res => (new useritem(res)))
        await informClient(json).then(res => {
          if (res.code == 1001) {
            update_status({
              statusType: 2,
              statementNo: low.statementNo,
              supplierConfirm: 1
            }).then(() => {
            })
            this.$message({
              message: '发送成功',
              type: 'success'
            });
            this.gettableData()
            this.userDeta = false
          }
        })
      })
    },
    /**结算数量合计*/
    combined(arr) {
      let num = 0
      arr.forEach(res => {
        num = Number(res.num) + num
      })
      return num.toFixed(2)
    },
    /**结算金额合计*/
    combined1(arr) {
      let num = 0
      arr.forEach(res => {
        num = Number(res.closeSumMoney) + num
      })
      return num.toFixed(2)
    },
    /**导航栏切换*/
    choose(pages) {
      this.pagesLoading = true
      this.currenindex = pages;
    },
    /**获取对应的搜搜添加*/
    getsearchData() {
      let _this = this
      if (_this.currenindex == 1) {
        getContractVoList({ contractTypeId: 3, dataType: 2 }).then(res => {
          this.searchData = res.data
        })
      }
      if (_this.currenindex == 2) {
        getContractVoList({ contractTypeId: 3, dataType: 2 }).then(res => {
          this.searchData = res.data
        })
      }
      if (_this.currenindex == 3) {
        getContractVoList({ contractTypeId: 3, dataType: 2 }).then(res => {
          this.searchData = res.data
        })
      }
    },
    /**合同列表选中*/
    setradio(data) {
      this.searchradio = JSON.stringify(data)
    },
    /**确定选择运输合同*/
    submitsearch() {
      let item = JSON.parse(this.searchradio)
      this.tableParam.pumpingTeamId = item.supplierId
      this.tableParam.pumpingTeam = item.supplierName
      this.searchText = item.supplierName + '-' + item.contractNumber
      this.search = false
    },

    /**查询 */
    pagesgettableData() {
      let _this = this
      if (_this.currenindex == 1) {
        // _this.tableParam.pumpingTeamId = '0e5d24e6d43d4861acf98d664752e565'
        if (!_this.tableParam.pumpingTeamId) {
          this.$message({
            message: '警告哦，请先选择供应商',
            type: 'warning'
          });
          return
        }
        if (_this.datePicker.length == 0) {
          this.$message({
            message: '警告哦，请先选择时间段',
            type: 'warning'
          });
          return
        }
      }
      this.gettableData()
    },
    /**表格选中数据*/
    tableChange(val) {
      this.generate.punList = val

    },
    /**生成结算单*/
    statements() {
      let data = new Object()
      data.punList = new Array()
      data.startTime = this.tableParam.startTime
      data.endTime = this.tableParam.endTime
      data.pumpingTeamId = JSON.parse(this.searchradio).supplierNameId
      data.contractId = JSON.parse(this.searchradio).contractId
      data.pumpingTeam = JSON.parse(this.searchradio).supplierName
      this.generate.punList.forEach(res => {
        res.list.forEach(item => {
          let data1 = JSON.parse(JSON.stringify(res))
          delete data1.list
          data.punList.push({ ...item, ...data1 })
        })
      })
      generateStatement(data).then(res => {
        this.billDetails = res.data
        this.billList = res.data.list
        this.billDeta = true
        console.log(res.data)
      })
    },
    show(low) {
      this.low = low
      queryMany({ finalStatementNum: low.statementNo }).then(res => {
        this.billDetails1 = res.data
        this.billDeta1 = true
      })
    },
    /**重置*/
    init() {
      this.datePicker = []
      this.tableParam = this.$options.data().tableParam
      this.gettableData()
    },
    /**提交结算单*/
    combinedSubmit(type) {
      let _this = this
      if (type == 3) {
        _this.$router.push({ name: "sign_Wise_rentunit3", query: { id: this.low.statementNo, type: 1 } });
        return
      }
      let data = new Object()
      data.statement = new Object()
      data.dbtype = 2
      data.type = 2
      data.list = this.billList
      data.detailsList = this.billDetails.punList
      data.statement.contractId = this.billDetails.contractId
      data.statement.statementNo = this.billDetails.finalStatementNum
      data.statement.unitId = this.billDetails.pumpingTeamId
      data.statement.unitName = this.billDetails.pumpingTeam
      data.statement.startTime = this.tableParam.startTime
      data.statement.endTime = this.tableParam.endTime
      data.statement.statementType = 2
      new Promise(resolve => {
        html2canvas(self.$refs.html).then((canvas) => {
          canvas.toBlob((blob)=>{
            const file = new File([blob], '结算截图.jpg', {type: 'image/jpg'});
            const params = new FormData();
            params.append('file', file);
            uploadFile(params).then(res => {
              if (res.code === 1001) {
                resolve(res.data.fileUrl)
              }
            })
          })
        })
      }).then(value => {
        data.statement.picture = value;
        saveOrUpdate(data).then(res => {
          if (res.code == 1001) {
            this.billDeta = false
            if (type == 2) {
              _this.$router.push({ name: "sign_Wise_rentunit3", query: { id: res.data, type: 1 } });
              return
            }
            this.gettableData()
          }
        })
      })
    },
    sizeChange(value) {
      this.tableParam.pageSize = value;
      this.pagesgettableData();
    },
  },
};
</script>

<style lang="scss" scoped>
.dialoginfo {
  padding: 20px 20px 0 20px;
  max-height: 400px;
  overflow: auto;
}
.tabtop {
  width: 571px;
}
.el-input,
.el-select {
  width: 240px;
}
/*
 <el-link class="table_link" :underline="false">查看配合比</el-link>*/
.table_link {
  margin: 0 10px;
  color: $bg_color;
  cursor: pointer;
}

.table_link:hover {
  opacity: 0.8;
}
.bill_top {
  display: flex;
  justify-content: space-between;
  .text {
    font-weight: 600;
    color: #000;
  }
}
.bill_title {
  font-size: 18px;
  font-weight: 600;
  padding: 15px 0;
}
.bill_title1 {
  font-size: 18px;
  font-weight: 600;
  padding: 20px 0;
}
.bill_subtitle {
  padding: 20px 0;
  > span {
    padding-right: 20px;
  }
  .text {
    color: #000;
  }
}
.combined {
  border: 1px solid #ebeef5;
  text-align: center;
  line-height: 40px;
}
</style>
